package com.aaron.Caitlyn.system.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.Caitlyn.common.util.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aaron.Caitlyn.system.dao.MenuMapper;
import com.aaron.Caitlyn.system.service.MenuService;

@Service
public class MenuServiceImpl implements MenuService {

	@Autowired
	private MenuMapper menuMapper;
	
	@Override
	public  Map<String, Object> getMenu(PageRequest pageRequest) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("page", pageRequest);
		Long totalRecord =  menuMapper.getMenuCount(resultMap);
		resultMap.put("records", totalRecord);
		int rows = pageRequest.getRows();
		resultMap.put("total", totalRecord % rows == 0 ? totalRecord/rows : totalRecord/rows + 1);//总页数
		resultMap.put("rows", menuMapper.getMenu(resultMap));
		return resultMap;
	}

}
